package com.heartgo.myutil;

import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class DataCoverUtil {

    /**
     * json字符串转数组
     * @param jsonString
     * @return
     */
    public static String[] jsonToArray(String jsonString) {
        try {
            String [] jsonArray = new String[]{};
            List list = new ArrayList<>();
            JSONObject object = JSONObject.fromObject(jsonString);

            Iterator iterator = object.keys();

            while (iterator.hasNext()){
                list.add(object.getString(iterator.next().toString()));
            }
            return (String[]) list.toArray(jsonArray);
        } catch (Exception e) {
            throw new IllegalArgumentException("data cover filed");
        }

    }
}
